package com.example.springmvc.controller;


import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Slf4j
@RestController
public class CalculateController {
    @RequestMapping("/calc")
    public String calc(Integer num1, Integer num2) {
        if (num1 == null || num2 == null) {
            log.error("参数异常");
            //<h1><a href='javascript:history.go(-1);'>返回</a></h1>回退
            return "计算失败  <h1><a href='javascript:history.go(-1);'>返回</a></h1>";
        }
        return "<h1>结果:" + (num1 + num2) + "</h1>" + "<h1><a href='javascript:history.go(-1);'>返回</a></h1>";
    }

}
